﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ActionTrackerDAO.Mapeos;
using FluentNHibernate.Cfg;
using FluentNHibernate.Cfg.Db;
using NHibernate;

namespace ActionTrackerDAO.Base
{
    public sealed class NHConfiguration
    {
        public static readonly ISessionFactory sessionFactory;

        static NHConfiguration()
        {
            if(sessionFactory == null)
                sessionFactory = CreateSessionFactory();
         }

        private static ISessionFactory CreateSessionFactory()
        {
            //Configuración local
            return Fluently.Configure()
                .Database(MsSqlConfiguration.MsSql2008
                              .ConnectionString(x => x
                                .TrustedConnection()
                                .Server(@"maxi-laptop\sqlexpress")
                                .Database("BDActionTracker")))
                                .Mappings(m => m.FluentMappings.AddFromAssemblyOf<AccionMap>())
                .BuildSessionFactory();
            
            //Configuración remota
            //return Fluently.Configure()
            //    .Database(MsSqlConfiguration.MsSql2008
            //                  .ConnectionString("Data Source=BDActionTracker.mssql.somee.com; " +
            //                                    "Initial Catalog=BDActionTracker; " +
            //                                    "User ID=valep21; " +
            //                                    "Password=Valeriap21; " +
            //                                    "MultipleActiveResultSets=true;"))
            //                    .Mappings(m => m.FluentMappings.AddFromAssemblyOf<AccionMap>())
            //    .BuildSessionFactory();

        }

    }
}
